<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
#parse("page_include.html")
<style type="text/css">
#processContainer {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	border: 1px solid #CCC;
}

#map {
	width: 100%;
	height: 100%;
}

.mark-executing {
	position: absolute;
	border: 1px solid red;
	font-size: 0px;
}

.mark-completed {
	position: absolute;
	border: 1px solid red;
	font-size: 0px;
}

.mark-notstart {
	position: absolute;
	border: 1px solid #000000;
	font-size: 0px;
}

.bodyCss {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.processImgCss {
	width: 100%;
	height: 100%;
}
</style>
</head>
<body clsss="bodyCss">
	<div id="processContainer">
		<div id="map">
			<img clsss="processImgCss" alt="#springMessage('processDiagramNull')"
				src="${rc.contextPath}/activiti/getPDiagramBypiid.do?piid=${piid}">
		</div>
	</div>
	<div id="processDefInfo" data-type="window" title="流程节点信息"
		data-defs="modal:true,minimizable:false,maximizable:false,closed:true"
		style="width: 600px; height: 300px; padding: 10px;">内容</div>
	<script type="text/javascript">
		var x_relative=25;//本流程图片X相对偏移
		var y_relative=45;//本流程图片Y相对偏移
        function addTaskPointInfo(p, taskItem) {
            var div = document.createElement("div");
            div.onclick = function(obj) {
                var processInfo = "任务ID:" + obj.target.id + " <br>流程定义ID:" + $(obj.target).attr("pdid") + " <br>任务默认执行者:"
                        + $(obj.target).attr("assignee") + "  <br>任务描述:" + $(obj.target).attr("description");
                var window = $("#processDefInfo").window("center");
                window.window({ "content" : processInfo });
                window.window("open");
            };
            div.id = taskItem.taskId;
            div.className = "mark-notstart";
            div.style.width = taskItem.width + "px";
            div.style.height = taskItem.height + "px";
            var x = taskItem.x-x_relative;
            var y = taskItem.y-y_relative;
            div.style.left = x + "px";
            div.style.top = y + "px";
            p.appendChild(div);
            $("#" + taskItem.taskId).attr("piid", taskItem.piid);
            $("#" + taskItem.taskId).attr("pdid", taskItem.pdid);
            $("#" + taskItem.taskId).attr("assignee", taskItem.assignee);
            $("#" + taskItem.taskId).attr("description", taskItem.description);
        }
        function addTaskPointByPiid(piid) {
            var url = '${rc.contextPath}/activiti/getTaskPointInfoByPiid.do';
            var data = { "piid" : piid };
            ajaxPost(url, data, function(rs) {
                var container = document.getElementById("processContainer");
                addTaskPointInfo(container, rs);
            });
        }
        function addTaskPointByPdid(pdid) {
            var url = '${rc.contextPath}/activiti/getTaskPointInfoByPdid.do';
            var data = { "pdid" : pdid };
            ajaxPost(url, data, function(rs) {
                var container = document.getElementById("processContainer");
                for ( var i = 0; i < rs.length; i++) {
                    addTaskPointInfo(container, rs[i]);
                }
            });
        }
        $(document).ready(function() {
            var piid = '${piid}';
            var pdid = '${pdid}';
            if (piid != "NULL") {
                addTaskPointByPiid(piid);
            } else {
                addTaskPointByPdid(pdid);
            }
        });
    </script>
</body>
</html>
